{include file="public/header" /}
<form class="layui-form">
	<input type="hidden" name="test_id" value="{$find['test_id']}">
	<div class="layui-form-item">
		<label class="layui-form-label">文本</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" id="test_input" placeholder="请输入文本" value="{$find['test_input']}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">富文本</label>
		<div class="layui-input-block">
			<textarea class="layui-textarea" id="test_rich" placeholder="请输入富文本">{$find['test_rich']}</textarea>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">参照</label>
		<div class="layui-input-block">
			<select id="test_reference">
				<option value="1" {$find['test_reference']==1?'selected':''}>开启</option>
				<option value="0" {$find['test_reference']==0?'selected':''}>关闭</option>
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">时间戳</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" id="test_time" value="{$find['test_time']}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">日期</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" id="test_data" value="{$find['test_data']}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">日期时间</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" id="test_datatime" value="{$find['test_datatime']}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">图片</label>
		<div class="layui-input-inline">
			<button type="button" class="layui-btn layui-btn-fluid" id="up_test_img">上传图片</button>
		</div>
		<div class="layui-form-mid layui-word-aux">支持png,jpg,gif</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">图片预览</label>
		<div class="layui-input-block">
			<div class="layui-upload-list" id="demo_test_img" style="width:90%;float:left;">
				{if(!empty($find['test_img']))}
					<div class="upload_pic_li" style="position:relative; width:100px; float:left; margin:0 10px 10px 0">
						<img style="width:100px;height:100px;" src="{$find['test_img']}" class="layui-upload-img" onmouseover="show_img(this)" onmouseleave="hide_img()">
						<input type="hidden" name="test_img" value="{$find['test_img']}"/>
						<a class="close-img" href="javascript:;" onclick="deleteImage('{$find[\'test_img\']}',this);return false;"></a>
					</div>
				{/if}
			</div>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">百度富文本</label>
		<div class="layui-input-block">
			<textarea  id="test_rich_baidu" style="width:100%;" placeholder="请输入百度富文本">{$find['test_rich_baidu']}</textarea>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">网址链接</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" id="test_url" placeholder="请输入网址链接" value="{$find['test_url']}">
		</div>
	</div>
</form>
<div class="layui-form-item" style="margin-top:10px;">
	<div class="layui-input-block">
		<button type="button" class="layui-btn" onclick="save()">保存</button>
	</div>
</div>
<script type="text/javascript" charset="utf-8" src="/static/third/kindeditor/kindeditor-all-min.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/third/kindeditor/lang/zh-CN.js"></script>
<script type="text/javascript">
	layui.use(['layer','form','upload','laydate'],function(){
		form = layui.form;
		layer = layui.layer;
		$ = layui.jquery;

		upload = layui.upload;
		upload.render({
			elem: "#up_test_img",
			url: "{$config['admin_route']}index/upload_img",
			multiple: true,
			done: function(res,title){
				if(res.code > 0){
					return layer.msg("上传失败，"+res.msg);
				}else{
					$("#demo_test_img").append('<div class="upload_pic_li" style="position:relative; width:100px; float:left; margin:0 10px 10px 0"><img style="width:100px;height:100px;" src="'+ res.url +'" class="layui-upload-img" onmouseover="show_img(this)" onmouseleave="hide_img()"><input type="hidden" name="test_img" value="'+res.data+'"/><a class="close-img" href="javascript:;" onclick="deleteImage(\''+res.data+'\',this);return false;"></a></div>');
				}
			}
		});

		laydate = layui.laydate;
		laydate.render({
			elem: '#test_time',
			type: 'datetime'
		});
		laydate.render({
			elem: '#test_data'
		});
		laydate.render({
			elem: '#test_datatime',
			type: 'datetime'
		});
	});

	KindEditor.ready(function(K) {
		window.editor = K.create('#test_rich_baidu',{
			items : [
				'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
				'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
				'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
				'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
				'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
				'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'multiimage',
				'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
				'anchor', 'link', 'unlink', '|', 'about'
			],
			minHeight:'350px',
			allowFileManager : true,
			uploadJson : "{$config['admin_route']}index/upload_imgs_kin",
			afterUpload: function(){this.sync();}, //图片上传后，将上传内容同步到textarea中
			afterBlur: function(){this.sync();},   //失去焦点时，将上传内容同步到textarea中
		});
	});

	function save(){
		$.post("{$config['admin_route']}Bewtest/test_static_edit",$('form').serialize(),function(res){
			if(res.code>0){
				layer.msg(res.msg,{'icon':2});
			}else{
				layer.msg(res.msg,{'icon':1});
				setTimeout(function(){parent.window.location.reload();},1000);
			}
		},'json');
	}
</script>
{include file="public/tail" /}